<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.*"%>
<%@ page import="weaver.hrm.User"%>
<%@ page import="com.weaver.sso.client.validation.Assertion" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.integration.util.SessionUtil" %>
<%@ page import="com.weaver.sso.client.util.AbstractCasFilter" %>
<%@ page import="com.weaver.sso.client.authentication.AttributePrincipal" %>
<%
    BaseBean bb=new BaseBean();
    bb.writeLog("进入测试1");
    String SSOLoginName="";

    Map<String,Object> arr;

    try{

        Assertion assertion = (Assertion) request.getSession().getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
        bb.writeLog("进入测试11"+assertion);
        AttributePrincipal principal = assertion.getPrincipal();

        arr=principal.getAttributes();

        SSOLoginName = principal.getName();

    }catch(Exception e){

    }

    //1.拿工号
    Assertion assertion = (Assertion) request.getSession(true).getAttribute("_const_cas_assertion_");
    bb.writeLog("进入测试2"+assertion);
    Map attributes = assertion.getAttributes();
    bb.writeLog("进入测试3");
    String emamil = (String) attributes.get("email");
    bb.writeLog("当前邮箱"+emamil);
    RecordSet rs = new RecordSet();
    //查询OA中是否有username的人员
    String sql = "select * from HrmResource where email='" + emamil + "'";
    bb.writeLog("当前用户信息==" + sql);
    rs.execute(sql);
    User user_new = null;
    if (rs.next()) {
        String strUid = rs.getString("id");
        bb.writeLog("当前登录用户"+strUid);
        //OA有相关人员
        User user = (User) request.getSession(true).getAttribute("weaver_user@bean");
        if (user == null) {
            bb.writeLog("用户session还未构造，新登录");
        } else if ((user != null && !user.getLoginid().equals("rzry"))) {
            bb.writeLog("老用户session=" + user.getLoginid() + " 新用户session=" + "rzry");
        }
        if (user == null || (user != null && !user.getLoginid().equals("rzry"))) {
            // 人员还未登录，构造人员
            SessionUtil.createSession(strUid, request, response);
        } else {
            // 人员已登录
            user_new = user;
        }
        //session构建后查询当前人员的requestid
//        String strRequestid = autoLogin.getRequestid(strUid);
//        bb.writeLog("当前入职人员的流程id"+strRequestid);
        String strRequestUrl="/spa/workflow/static4form/index.html?_rdm=1575251636288#/main/workflow/req?requestid=251255";
        bb.writeLog("当前请求流程路径"+strRequestUrl);
        response.sendRedirect(strRequestUrl);
    }
%>